package com.gitee.ice1938.module.admin.app.manage.appdetail;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.gitee.ice1938.module.admin.app.manage.appbasetype.AppBaseTypeEntity;
import com.gitee.ice1938.module.admin.app.manage.appbasetype.AppBaseTypeService;
import com.gitee.ice1938.module.admin.app.manage.appownerinfo.AppOwnerInfoEntity;
import com.gitee.ice1938.module.admin.app.manage.appownerinfo.AppOwnerInfoService;

/**
 * AppDetailController
 * 
 * 
 * @author ice1938@qq.com 2019-12-2 10:38:57
 *
 */
@Controller
@RequestMapping("/appdetail")
public class AppDetailController {

	@Autowired
	private AppDetailService appDetailService;

	@Autowired
	private AppOwnerInfoService appOwnerInfoService;

	@Autowired
	private AppBaseTypeService appBaseTypeService;

	/**
	 * 页面索引
	 * 
	 * @param request
	 *            请求
	 * @param response
	 *            响应
	 * @param model
	 *            Model
	 * @return 页面
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
		if (request.getParameter("owner") == null) {
			throw new RuntimeException("owner is null");
		}
		AppOwnerInfoEntity appOwnerInfoEntity = appOwnerInfoService.findOwnerInfo(request.getParameter("owner"));
		model.addAttribute("ownerInfo", appOwnerInfoEntity);

		Page<AppBaseTypeEntity> types = appBaseTypeService.findAppBaseTypeData(new HashMap<String, Object>(), null, null);
		model.addAttribute("types", types.getContent());
		return "module/admin/appdetail/view_list";
	}
}
